<?php
/**
 * Created by PhpStorm.
 * FileName: IndexController.php
 * User: Administrator
 * Date: 2018/5/22
 * Time: 14:32
 */

namespace WeiXin\Controller;

use Admin\Model\NewsModel;
use Admin\Model\NewsCateModel;

/**
 * 资讯
 * Class InfoController
 * @package WeiXin\Controller
 */
class InfoController extends BaseController {

    private $newsModel;
    private $newsCateModel;

    function __construct() {
        $this->newsModel = new NewsModel();
        $this->newsCateModel = new NewsCateModel();
        parent::__construct();
    }

    public function index() {
        $tpl = I('tpl','index');
        $row = $this->newsCateModel->where(array('id' => I('id')))->find();
        $this->assign('cateId',$row['id']);
        $this->assign('cateName',$row['cate_name']);
        $this->assign('pageTitle',$row['cate_name']);
        $this->display($tpl);
    }

    public function detail() {
        $id = I('id');
        $row = $this->newsModel->where(array('id' => $id))->find();
        $cate = $this->newsCateModel->where(array('id' => $row['cate_id']))->find();
        $row['content'] = checkAttUrl(htmlspecialchars_decode($row['content']));
        $this->assign('row',$row);
        $this->assign('cateName',$cate['cate_name']);
        $this->assign('pageTitle',$cate['cate_name']);
        $this->display();
    }
}